home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ian & Stuart's Australian Mac 1
/
Ian and Stuart's One (Australia).iso
/
Awards
/
MacUser Shareware Awards 94
/
System Enhancements
/
1. KeyQuencer 1.2
/
Developer’s toolkit
/
Extension code
/
Action.h
< prev
next >
Wrap
Text File
|
1994-07-31
|
3KB
|
61 lines
// =============================================================================
// KEYQUENCER EXTENSIONS SAMPLE PROJECT HEADER - VERSION 1.2 - AUGUST 1994
// ©1994 Alessandro Levi Montalcini <lmontalcini@pmn.it>
// Don’t forget to send me any cool extensions you create!
// This text looks best in monaco 9 font, 4 spaces per tab, no wrapping
#ifndef _H_action
#define _H_action
// =============================================================================
// The Extension.c file provides a simple way to set up your globals
// and dispatch the extension messages. You don't have to call SetUpA4() or
// RestoreA4() in the init() and run() routines because the main() routine in
// the Extension.c file has done all the dirty work for you.
// You can use the Extension.c file without modifications and add your own
// code to the Action.c file, inside the existing init() and run() routines.
// =============================================================================
// PROTOTYPES:
short run (ParamsPtr params, MachineHandle mac, GluePtr glue);
short init (MachineHandle mac, GluePtr glue);
long SetupExtensionWorld (void);
void RestoreExtensionWorld (long world);
// =============================================================================
// The SetupExtensionWorld and RestoreExtensionWorld are needed if you
// install patches or callbacks that may be called by the system and still
// want to access your extension globals. Here's an example of how to do it:
/*
long gOldTrapAddress; // this is a global variable (the original trap address)
short init(MachineHandle mac, GluePtr glue) // this is your extension's init() routine
{
gOldTrapAddress = (long)GetToolTrapAddress(_TheTrapToPatch);
SetToolTrapAddress((UniversalProcPtr)MyTrapPatch, _TheTrapToPatch);
return kExtNoError;
}
pascal void MyTrapPatch(void) // this is your trap patch
{ // (usually declared as pascal for toolbox traps)
pascal void (*OriginalTrap)(void);
long world;
world = SetupExtensionWorld(); // get access to your extension's globals
// you may use your globals here
OriginalTrap = (void*)gOldTrapAddress; // gOldTrapAddress won't be available after RestoreExtensionWorld()
RestoreExtensionWorld(world); // but the local variable will be OK
(*OriginalTrap)(); // this is both a head and a tail patch, which is a Bad Thing
} // (you have to use some assembler to avoid it)
*/
// =============================================================================
#endif // _H_action
// =============================================================================